package com.fadadianqi.mall.product.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.mall.product.dao.ItemSPUDAO;
import com.fadadianqi.mall.product.model.ItemSPU;
import com.yeqiangwei.commons.util.Pagination;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by aroot on 2/7/14.
 */
@Component
public class ItemSPUDAOImpl extends GenericDAOSuport<String, ItemSPU> implements ItemSPUDAO {

    @Override
    protected Class<?> getObjectClass() {
        return ItemSPU.class;
    }

    @Override
    protected String getTableName() {
        return "mall_item_spu";
    }

    @Override
    public int countAll() {
        return super.countAll(null);
    }

    @Override
    public int countAllNotIndexed() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("isIndexed", Boolean.FALSE);
        return super.countAll(map);
    }

    @Override
    public List<ItemSPU> findAllNotIndexed(Pagination pagination) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("isIndexed", Boolean.FALSE);
        map.put("pagination", pagination);
        return super.findByPropertys(map);
    }
}
